<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ include file="/WEB-INF/jsp/business/include/doctype.jsp" %>
<link rel="stylesheet" type="text/css" href="${requestScope.contextPath}/js/jquery-ui-1.8.14.custom/css/ui-lightness/jquery-ui-1.8.14.custom.css" />
<script type="text/javascript">
	function formCheck() {
		var frm = document.form;
		if(trim(frm.subject.value) == "") {
			alert("제목을 입력하세요.");
			frm.subject.value="";
			frm.subject.focus();
			return;
		}
		if(trim(frm.startdate.value) == "") {
			alert("회의일자가 없습니다.");
			frm.startdate.value="";
			frm.startdate.focus();
			return;
		}
		if(trim(frm.memo.value) == "") {
			alert("내용을 입력하세요.");
			frm.memo.value="";
			frm.memo.focus();
			return;
		}
		if (confirm('자원예약 수정하시겠습니까?')) {
			frm.submit();
		}
		return;
	}
	
	$(function() {
		var dates = $('#startdate').datepicker({
			showOn: "button",
			buttonImage: "${requestScope.contextPath}/images/reservation/cal1.gif",
			buttonImageOnly: true,
			numberOfMonths: 1,
			dateFormat: 'yy-mm-dd',
			showMonthAfterYear:true,
			showButtonPanel: true,
			monthNamesShort: ['1월','2월','3월','4월','5월','6월','7월','8월','9월','10월','11월','12월'],
			dayNamesMin: ['일', '월', '화', '수', '목', '금', '토'],
			onSelect: function(selectedDate) {
				var option = this.id == "startdate" ? "minDate" : "maxDate";
				var instance = $(this).data("datepicker");
				var date = $.datepicker.parseDate(instance.settings.dateFormat || $.datepicker._defaults.dateFormat, selectedDate, instance.settings);
				dates.not(this).datepicker("option", option, date);
			}
		});
	});
	
	

	function chkDate() {
		
		var selStartDateHour = form.StartHour.options[form.StartHour.options.selectedIndex].value;
		var selEndDateHour = form.EndHour.options[form.EndHour.options.selectedIndex].value;
		var selStartDateMin = form.StartMin.options[form.StartMin.options.selectedIndex].value;
		var selEndDateMin = form.EndMin.options[form.EndMin.options.selectedIndex].value;

		if(Number(selStartDateHour) > Number(selEndDateHour)) {
		
			alert("시작 시간이 종료 시간 보다 큽니다.");
			document.form.StartHour.value = document.form.EndHour.value;
			return false; 
		}
				
		if( Number(selStartDateHour) >= Number(selEndDateHour) && Number(selStartDateMin) > Number(selEndDateMin) ) {
			alert("시작 분이 종료 분 보다 큽니다."); 
			document.form.StartMin.value = "00";
			return false; 
		}
		
		return true;
	}
</script>

</head>
<body>
	<div id="wrap">
		<div class="header">
			<h1>자원예약</h1>
		</div><!-- // header -->
		<div class="content reservation">
		<form name="form" action="${requestScope.contextPath}/business/mResourceRes/mResourceResModify.do" method="post" onsubmit="return false;">
			<input type="hidden" name="ResourceID" value="${map.ResourceID}" />
			<input type="hidden" name="ResourceCode" value="${map.ResourceCode}" />
			<input type="hidden" name="Type" value="${map.ResourceType}" />
			<input type="hidden" name="ResourceNM" value="${map.Resource_NAME}" />
			<input type="hidden" name="startdate" value="${map.StartDate}" />
			<input type="hidden" name="StartHour" value="${map.StartDateHour}" />
			<input type="hidden" name="StartMin" value="${map.StartDateMin}" />
			<input type="hidden" name="EndHour" value="${map.EndDateHour}" />
			<input type="hidden" name="EndMin" value="${map.EndDateMin}" />
			<input type="hidden" name="ResType" value="${ResType}" />
			<input type="hidden" name="ResTypeCatid" value="${ResTypeCatid}" />
			<input type="hidden" name="ResTypeNM" value="${ResTypeNM}" />
			
			<fieldset>
				<legend>예약 등록</legend>
				<table summary="" cellspacing="0" class="table3">
					<caption>예약등록</caption>
					<colgroup>
						<col style="width:60px" />
						<col style="width:80%" />
					</colgroup>
						<tbody>
							<tr>
								<th scope="row">예약자</th>
								<td>${sessionScope.SESSION_USER_INFO.UserName}</td>
							</tr>
							<tr>
								<th scope="row"><label for="title">회의제목</label></th>
								<td><input type="text" name="subject" id=subject value="${map.Subject}" /></td>
							</tr>
							<tr>
								<th scope="row"><label for="place">회의장소</label></th>
								<td>${map.Resource_NAME}</td>
							</tr>
							<tr>
								<th scope="row"><label for="date">회의일자</label></th>
								<td>${map.StartDate}</td>
							</tr>
							<tr>
								<th scope="row">회의시간</th>
								<td>
									<p><select title="회의시간" name="StartHour" onChange="javascript:chkDate();" disabled="disabled" >
										<c:forEach var = "i" begin = "7" end = "24" step = "1" varStatus = "status">
											<option value="<c:if test="${i <= 9}">0</c:if>${i}" <c:if test="${i <= map.StartDateHour}">selected="selected"</c:if>><c:if test="${i <= 9}">0</c:if>${i}</option>
										</c:forEach>
									</select> 시 
									<select title="회의시간" name="StartMin" onChange="javascript:chkDate();" disabled="disabled">
										<c:forEach var = "i" begin = "00" end = "50" step = "10" varStatus = "status">
											<option value="<c:if test="${i < 10}">0</c:if>${i}" <c:if test="${i <= map.StartDateMin}">selected="selected"</c:if>><c:if test="${i < 10}">0</c:if>${i}</option>
										</c:forEach>
									</select> 분 ~</p>
									<p><select title="회의시간" name="EndHour" onChange="javascript:chkDate();" disabled="disabled">
										<c:forEach var = "i" begin = "7" end = "24" step = "1" varStatus = "status">
											<option value="<c:if test="${i <= 9}">0</c:if>${i}" <c:if test="${i <= map.EndDateHour}">selected="selected"</c:if>><c:if test="${i <= 9}">0</c:if>${i}</option>
										</c:forEach>
									</select> 시 
									<select title="회의시간" name="EndMin" onChange="javascript:chkDate();" disabled="disabled">
										<c:forEach var = "i" begin = "00" end = "50" step = "10" varStatus = "status">
											<option value="<c:if test="${i < 10}">0</c:if>${i}" <c:if test="${i <= map.EndDateMin}">selected="selected"</c:if>><c:if test="${i < 10}">0</c:if>${i}</option>
										</c:forEach>
									</select> 분 </p>
								</td>
							</tr>
							<tr>
								<th scope="row"><label for="memo">내용</label></th>
								<td><textarea cols="28" rows="2" id="memo" name="memo" class="comment">${map.Contents}</textarea></td>
							</tr>
						</tbody>
				</table>
			</fieldset>
		<p class="btn_area2"><img src="${requestScope.contextPath}/images/btn/btn_modify.gif" alt="수정" onclick="formCheck();" style="cursor: pointer;" /> <img src="${requestScope.contextPath}/images/btn/btn_reset.gif" alt="취소" onclick="history.back();" /></p>
		</form>
		</div><!-- // content -->
	</div><!-- // wrap -->
</body>
</html>